package com.apes.crm.business.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.scm.masterdata.area.model.Area;
import com.apes.scm.masterdata.party.model.PartyRole;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * @Classname 保险公司明细
 * @Description TODO
 * @Date 2020年9月1日17:58:26
 * @Created by zzx
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = InsuranceCompanyDetail.CONST_TABLE_NAME)
public class InsuranceCompanyDetail extends Model {
    public static final String CONST_TABLE_NAME = "crm_insurance_company_detail";

    @Id
    @Column(name = "id", length = 32)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "保险公司明细")
    @Comment("编码")
    private String id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "province_id", referencedColumnName = "id")
    @Comment("省份")
    private Area province; //省份

    @ManyToOne
    @JoinColumn(name = "city_id", referencedColumnName = "id")
    @Comment("城市")  //城市
    private Area city;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "supplier_id", referencedColumnName = "id")
    @Comment("供应商")
    private PartyRole supplier;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "client_id", referencedColumnName = "id")
    @Comment("客户")
    private PartyRole client;

    @Column(name = "APP_Code", length = 32)
    @Comment("APP对应编码")
    private String APPCode;

    @ManyToOne(optional = false)
    @JoinColumn(name = "insurance_Company_id", referencedColumnName = "id", nullable = false)
    @Comment("保险公司")
    private InsuranceCompany insuranceCompany;

    @Column(name = "report_number_standard", length = 32)
    @Comment("报案号标准")
    private String reportNumberStandard;
}
